<?php  
 // session_start();


       // 如果$_POST不为空
          if(!empty($_POST)){

// 引用调用的函数
             $savepath = '';
           // print_r($_FILES);die; 


               // echo $_FILES['file'];die;
            if (!empty($_FILES['file']['name'][0])) {

              $filelist = array();

              // 数组重组
              foreach ($_FILES['url']['name'] as $key => $v) {
                 $filelist[$key]['name']=$_FILES['url']['name'][$key];
                 $filelist[$key]['type'] = $_FILES['url']['type'][$key];
                 $filelist[$key]['tmp_name']=$_FILES['url']['tmp_name'][$key];
                 $filelist[$key]['error']=$_FILES['url']['error'][$key];
                 $filelist[$key]['size']=$_FILES['url']['size'][$key];
              }
              
           // print_r($filelist);die;

              foreach ($filelist as $value) {
                
              $savepath = uploads($value);
             }
              
             
                  }

                
 $_POST['password']=md5($_POST['password']);


 $_rows= add('admin',$_POST);
// $data=getSelect('news',1,'id desc',"$offset,$per_page");

// //编写插入语句 
// echo  $sql = "insert into `admin`(`username`,`password`,`sex`,`age`,`url`)values('$username','$password','$sex','$age','$url')";
// die;
// //编写执行语句
// mysqli_query($link,$sql);
// //mysqli_affected_rows($link)语句可以检测语句是否执行成功
//   $_rows=mysqli_affected_rows($link);



//如果$_rows>0说明成功
if ($_rows>0) {
    echo '<script> alert ("管理员添加成功");location.href="index.php?c=admin&a=list&admin=1";</script>';die;
       
}else{

    echo '<script> alert ("管理员添加失败");history.go(-1);</script>';
        die;
}


}
$role = getSelect('role',1);

// print_r($role);die;

// print_r($role);die;
//链接news.html的语句
include (VIEW_PATH.$admin.'layout.html');

?>

